﻿/*
 * Copyright @ JuCheap All rights reserved.
 * 
 * 功能描述:工作单元接口
 * 作者: JuCheap
 * 时间: 04/02/2019 11:26:34
 */

using Microsoft.EntityFrameworkCore.Storage;
using System;
using System.Threading.Tasks;

namespace JuCheap.Core.IRepository
{
    /// <summary>
    /// 工作单元接口
    /// </summary>
    public interface IUnitWork : IDisposable
    {
        /// <summary>
        /// 事务
        /// </summary>
        IDbContextTransaction Transaction { get; }

        /// <summary>
        /// 开启事务
        /// </summary>
        Task<IDbContextTransaction> BeginTransactionAsync();

        /// <summary>
        /// 提交事务
        /// </summary>
        Task CommitAsync();

        /// <summary>
        /// 回滚事务
        /// </summary>
        Task RollbackAsync();

        /// <summary>
        /// 释放
        /// </summary>
        Task DisposeAsync();
    }
}
